package com.ruoyi.web.course.controller;
import java.util.Arrays;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.web.course.dto.TrainVideoPlayRecordDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.course.domain.TrainVideoPlayRecord;
import com.ruoyi.web.course.service.ITrainVideoPlayRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 视频播放记录Controller
 *
 * @author 范书铭
 * @date 2024-10-10
 */
@Api("视频播放记录")
@RestController
@RequestMapping("/course/record")
public class TrainVideoPlayRecordController extends BaseController {
    @Autowired
    private ITrainVideoPlayRecordService trainVideoPlayRecordService;

/**
 * 查询视频播放记录列表
 */
@ApiOperation("查询视频播放记录列表")
@PreAuthorize("@ss.hasPermi('course:record:list')")
@GetMapping("/list")
    public TableDataInfo list(TrainVideoPlayRecord trainVideoPlayRecord) {
        startPage();
        List<TrainVideoPlayRecordDto> list = trainVideoPlayRecordService.selectTrainVideoPlayRecordList(trainVideoPlayRecord);
        return getDataTable(list);
    }




    /**
     * 新增视频播放记录
     */
    @ApiOperation("新增视频播放记录")
    @PreAuthorize("@ss.hasPermi('course:record:add')")
    @Log(title = "视频播放记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TrainVideoPlayRecord trainVideoPlayRecord) {
        return toAjax(trainVideoPlayRecordService.save(trainVideoPlayRecord));
    }


    /**
     * 删除视频播放记录
     */
    @ApiOperation("删除视频播放记录")
    @PreAuthorize("@ss.hasPermi('course:record:remove')")
    @Log(title = "视频播放记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(trainVideoPlayRecordService.removeByIds(Arrays.asList(ids)));
    }
}
